/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package structures;
import java.util.Map;
import java.util.Iterator;
import com.google.common.collect.TreeMultimap;
/**
 *
 * @author Gonzalo
 */
public class Multimap {
    private TreeMultimap<Long,Long> multimap;
    private Iterator<Map.Entry<Long,Long>> it;
    private Map.Entry<Long,Long> key_value;
    private long num_puts=0;
    private long size_buffer;
    public Multimap(long size){
        multimap=TreeMultimap.create();
        size_buffer=size;
    }

    public void put(long _key, long _value){
        multimap.put(_key, _value);
        num_puts++;
    }

    public long getKey(){
        return key_value.getKey();
    }

    public long getValue(){
        return key_value.getValue();
    }

    public void init(){
        it=multimap.entries().iterator();
        next();
    }

    public boolean notNull(){
        return key_value!=null;
    }

    public void next(){
        if(it.hasNext())
            key_value=it.next();
        else
            key_value=null;
    }

    public boolean isFull(){
        return num_puts>=size_buffer;
    }

    public void clear(){
        num_puts=0;
        multimap.clear();
    }

}
